<include file="Public/header"/>
<include file="Public/menu"/>
<style type="text/css">
.edit-batch-list .ebatch-name{
	width:480px;
}
</style>
<!-- 内容页 -->
<div class="content-wrapper">
    <!-- 面包屑 -->
    <section class="content-header">
        <h1>
            领券中心
            <small>管理</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="{:U('Giftcode/index')}"><i class="fa fa-dashboard"></i> 营销</a></li>
            <li class="active">领券中心</li>
        </ol>
    </section>

    <!-- 内容 -->
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box box-info">
                    <div class="box-header with-border">
                        <h3 class="box-title">新增领券</h3>
                        <div class="box-tools">
                            <div class="btn-group pull-right" style="margin-right: 10px">
                                <a href="/Qgs/Giftcode/index" class="btn btn-sm btn-default"><i class="fa fa-list"></i>&nbsp;新增领券列表</a>
                            </div>
                        </div>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    <form id="form" action="/Qgs/Giftcode/add" method="post" accept-charset="UTF-8" class="form-horizontal">
                        <div class="box-body">

                            <div class="form-group">
                                <label class="col-sm-2 control-label">领取类型</label>
                                <div class="col-sm-6">
                                    <div class="no-margin">
                                        <select id="yh-type" name="type" class="form-control">
                                            <option value="1" selected="selected">1：新人礼券包</option>
                                            <option value="">暂无</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">领取名称</label>
                                <div class="col-sm-6">
                                    <div class="no-margin">
                                        <input name="name" value="" type="text" class="form-control" placeholder="领取名称">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">介绍</label>
                                <div class="col-sm-6">
                                    <div class="no-margin">
                                        <textarea name="des" class="form-control"></textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">启用状态</label>
                                <div class="col-sm-6">
                                    <div class="no-margin">
                                        开起 <input name="status" value="1" type="radio" class="">
                                        关闭<input name="status" value="0" type="radio" class="" checked="">
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">开始时间</label>
                                <div class="col-sm-6">
                                    <div class="input-group">
                                        <input class="form-control" type="text" id="start_time" name="start_time" value="" readonly />
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">结束时间</label>
                                <div class="col-sm-6">
                                    <div class="input-group">
                                        <input class="form-control" type="text" id="end_time" name="end_time" value="" readonly />
                                    </div>
                                </div>
                            </div>

                            <div class="form-group youhui_goods-area" style="display:block">
                                <label class="col-sm-2 control-label set_goods_name_values">赠送礼券</label>
                                <div class="col-sm-offset-2 ">
                                    <div class="box box-primary" style="width:580px;">
                                        <!-- /.box-header -->
                                        <div class="box-body">
                                            <ul class="todo-list ui-sortable edit-batch-list">
                                                <foreach name="discount_coupon_msg" item="v" >
                                                <li><input type="checkbox" name="gifg[]" value="{$v.id}"><a href="javascript:;" title="{$v.name}" class="text ebatch-name"> {$v.name}</a><div class="tools"></div></li>
                                                </foreach>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="box-body">
                                <div class="form-group 1">
                                    <label class="col-sm-2 control-label">图片</label>
                                    <div class="col-sm-6">
                                        <input type="file" id="image" data-max-file-count="1" />
                                        <input type="hidden" id="image_action"/>
                                    </div>
                                </div>
                            </div>


                        </div>
                        <div class="box-footer">
                            <div class="col-sm-2"></div>
                            <div class="col-sm-6">
                                <div class="btn-group pull-right">
                                    <button type="submit" class="btn btn-info pull-right submit_click">提交</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </section>
</div>
<!-- 底部 -->
<include file="Public/common_footer"/>
<script src="/Public/layer/layer.js"></script>
<link rel="stylesheet" href="/Public/admin/jedate/jedate.css" />
<script src="/Public/admin/jedate/jedate.js"></script>

<script type="text/javascript" src="/Public/admin/js/admin.yx.discount.js"></script>
<!--上传插件-->
<link rel="stylesheet" href="/Public/admin/fileinput/fileinput.min.css">
<script src="/Public/admin/fileinput/fileinput.min.js"></script>
<script>
    // 上传图片js
    $("#image").fileinput({
        overwriteInitial: true,
        dropZoneEnabled: false,
        uploadUrl: '/Qgs/upload/index/"',
        language: 'zh',
        showRemove: false,
        maxFileCount: 1,
        browseClass: 'btn btn-primary btn-docup',
        showPreview: true,
        uploadClass: 'btn btn-default btn-docup',
        allowedFileTypes: ["image"],
        browseLabel: "添加图片",
        uploadLabel: "上传图片",
        /*            initialCaption:"{$cat['cat_img']}",
         <if condition= "(!empty($cat['cat_img']))">
         initialPreview:['<img src="/Uploads/{$cat[cat_img]}" class="file-preview-image">' + '<div class="file-thumbnail-footer"><div class="file-footer-caption" title="{$cat[cat_img]}">{$cat[cat_img]}</div><div class="file-thumb-progress"><div class="progress"><div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width:100%;">100%</div></div></div> <div class="file-actions"><div class="file-footer-buttons"><button type="button" class="kv-file-upload btn btn-xs btn-default" title="Upload file" style="display: none;">   <i class="glyphicon glyphicon-upload text-info"></i></button><button type="button" class="kv-file-remove btn btn-xs btn-default" title="Remove file"><i class="glyphicon glyphicon-trash text-danger"  images="cat_img"></i></button></div><div class="file-upload-indicator" title="Uploaded"><i class="glyphicon glyphicon-ok-sign text-success"></i></div></div></div>']
         </if>*/
    }).on("fileuploaded", function (event, data, previewId, index) {
        var response = data.response;
        if (data.jqXHR.status == 200) {
            // ajax 成功返回数据写入
            $('.file-preview-frame').eq(index).append("<input class='abc' type='hidden' name='img' value='"+response+"'>");
        }
    });
    $("#image").on('filecleared', function(event) {
        $("#image_action").val(1);
    });

</script>